package net.martinimix.dao.order;

import net.martinimix.beans.support.PrototypeBeanFactory;
import net.martinimix.domain.order.Order;
import net.martinimix.domain.order.OrderHeader;
import net.martinimix.domain.order.OrderLine;

/**
 * Provides an abstract prototype aware order data access object capable of
 * creating new order and order header beans based on prototypes specified 
 * in the application context.
 * 
 * @author Scott Rossillo
 *
 */
public abstract class AbstractPrototypeAwareOrderDao extends PrototypeBeanFactory implements OrderDao {
	
	private final static String ORDER_BEAN = "order";
	private final static String ORDER_HEADER_BEAN = "orderHeader";
	private final static String ORDER_LINE_BEAN = "orderLine";
	
	
	/**
	 * Creates a new abstract order data access object.
	 */
	protected AbstractPrototypeAwareOrderDao() {
		super();
		super.addPrototype(ORDER_BEAN, Order.class);
		super.addPrototype(ORDER_HEADER_BEAN, OrderHeader.class);
		super.addPrototype(ORDER_LINE_BEAN, OrderLine.class);
	}
	
	/**
	 * Returns a new order bean.
	 * 
	 * @return a new <code>Order</code> bean
	 */
	protected Order createOrderBean() {
		return (Order) super.createBean(ORDER_BEAN);
	}
	
	/**
	 * Returns a new order header bean.
	 * 
	 * @return a new <code>OrderHeader</code> bean
	 */
	protected OrderHeader createOrderHeaderBean() {
		return (OrderHeader) super.createBean(ORDER_HEADER_BEAN);
	}
	
	/**
	 * Returns a new order line bean.
	 * 
	 * @return a new <code>OrderLine</code> bean
	 */
	protected OrderLine createOrderLineBean() {
		return (OrderLine) super.createBean(ORDER_LINE_BEAN);
	}
	
}
